<template>
	<view>
		<view class="input">
			<input type="text" v-model="name" :placeholder="'请输入'+title"/>
		</view>
		
		
		<view class="button" @click="confirm">
			确定
		</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				name:"",
				title:"",
				type:"",
			};
		},
		onLoad:function(e){
			this.name=e.name;
			this.type=e.type;
			if(e.type==0){
				this.title="昵称";
				uni.setNavigationBarTitle({
					title:"设置昵称"
				});
			}else{
				this.title="姓名";
				uni.setNavigationBarTitle({
					title:"设置姓名"
				});
			}
		},
		methods:{
			confirm:function(){
				uni.showLoading({
					title:"提交中",
				});
				var that=this;
				that.ajax(this.type==0?"/user/nickname":"/user/realname",{
					token:uni.getStorageSync("token"),
					name:this.name,
				},function(res){
					uni.showToast({
						title:"设置成功",
						icon:"success"
					})
					setTimeout(function(){
						uni.navigateBack({
							
						})
					},1000);
				});
			}
		}
	}
</script>

<style>
	.input{
		background: #ffffff;
		margin: 28upx;
		padding: 46upx;
		color: #4B4B4B;
		font-size: 28upx;
		box-shadow:0px 2px 20px 0px rgba(43,159,133,0.14);
		border-radius:12px;
	}
	.button{
		background: #45AA8C;
		line-height: 84upx;
		margin:138upx 146upx 0 146upx;
		border-radius: 46upx;
		font-size: 36upx;
		text-align: center;
		color: #ffffff;
	}
</style>
